#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>

int main()
{
    int pid;
    struct timespec start,end;
    clockid_t cpu_clock;
    clock_getcpuclockid(0,&cpu_clock);
    clock_gettime(cpu_clock,&start);
    pid = (int)getpid();
    clock_gettime(cpu_clock,&end);
    printf("%d used %ld ns + %lds \n",pid,end.tv_nsec-start.tv_nsec
        ,(long)end.tv_sec - (long)start.tv_sec);
    return 0;
}